﻿Imports Co9320.NamaAlert.Model

Namespace ViewModel.UISettings

    Public Class DataGridViewModel
        Inherits ViewModelBase

        Private _Group As Grouping.ProgramGroup = Grouping.ProgramGroup.None
        Public Property Group() As Grouping.ProgramGroup
            Get
                Return _Group
            End Get
            Set(ByVal value As Grouping.ProgramGroup)
                _Group = value
                OnPropertyChanged("Group")
            End Set
        End Property

        Private _GroupByAlertedProgram As Boolean
        Public Property GroupByAlertedProgram() As Boolean
            Get
                Return _GroupByAlertedProgram
            End Get
            Set(ByVal value As Boolean)
                _GroupByAlertedProgram = value
                OnPropertyChanged("GroupByAlertedProgram")
            End Set
        End Property

        Private _GroupByAlertTarget As Boolean
        Public Property GroupByAlertTarget() As Boolean
            Get
                Return _GroupByAlertTarget
            End Get
            Set(ByVal value As Boolean)
                _GroupByAlertTarget = value
                OnPropertyChanged("GroupByAlertTarget")
            End Set
        End Property

        Private _GroupByOffair As Boolean
        Public Property GroupByOffair() As Boolean
            Get
                Return _GroupByOffair
            End Get
            Set(ByVal value As Boolean)
                _GroupByOffair = value
                OnPropertyChanged("GroupByOffair")
            End Set
        End Property

#Region "For saving, no bind"
        ' MEMO DataGridのあるウィンドウから直接 値の取得・設定を行う 

        Private _SerializedWidths As String = ""
        Public Property SerializedWidths() As String
            Get
                Return _SerializedWidths
            End Get
            Set(ByVal value As String)
                _SerializedWidths = value
            End Set
        End Property

        Private _SerializedVisiblePositions As String = ""
        Public Property SerializedVisiblePositions() As String
            Get
                Return _SerializedVisiblePositions
            End Get
            Set(ByVal value As String)
                _SerializedVisiblePositions = value
            End Set
        End Property

#End Region

#Region "Column Width Properties"

        'Private _IconWidth As Double
        'Public Property IconWidth() As Double
        '    Get
        '        Return _IconWidth
        '    End Get
        '    Set(ByVal value As Double)
        '        _IconWidth = value
        '        OnPropertyChanged("IconWidth")
        '    End Set
        'End Property

        'Private _TitleWidth As Double
        'Public Property TitleWidth() As Double
        '    Get
        '        Return _TitleWidth
        '    End Get
        '    Set(ByVal value As Double)
        '        _TitleWidth = value
        '        OnPropertyChanged("TitleWidth")
        '    End Set
        'End Property

        'Private _StationNameWidth As Double
        'Public Property StationNameWidth() As Double
        '    Get
        '        Return _StationNameWidth
        '    End Get
        '    Set(ByVal value As Double)
        '        _StationNameWidth = value
        '        OnPropertyChanged("StationNameWidth")
        '    End Set
        'End Property

        'Private _CasterWidth As Double
        'Public Property CasterWidth() As Double
        '    Get
        '        Return _CasterWidth
        '    End Get
        '    Set(ByVal value As Double)
        '        _CasterWidth = value
        '        OnPropertyChanged("CasterWidth")
        '    End Set
        'End Property

        'Private _MemberOnlyWidth As Double
        'Public Property MemberOnlyWidth() As Double
        '    Get
        '        Return _MemberOnlyWidth
        '    End Get
        '    Set(ByVal value As Double)
        '        _MemberOnlyWidth = value
        '        OnPropertyChanged("MemberOnlyWidth")
        '    End Set
        'End Property

        'Private _OfficialTagWidth As Double
        'Public Property OfficialTagWidth() As Double
        '    Get
        '        Return _OfficialTagWidth
        '    End Get
        '    Set(ByVal value As Double)
        '        _OfficialTagWidth = value
        '        OnPropertyChanged("OfficialTagWidth")
        '    End Set
        'End Property

        'Private _FaceWidth As Double
        'Public Property FaceWidth() As Double
        '    Get
        '        Return _FaceWidth
        '    End Get
        '    Set(ByVal value As Double)
        '        _FaceWidth = value
        '        OnPropertyChanged("FaceWidth")
        '    End Set
        'End Property

        'Private _CommentCountWidth As Double
        'Public Property CommentCountWidth() As Double
        '    Get
        '        Return _CommentCountWidth
        '    End Get
        '    Set(ByVal value As Double)
        '        _CommentCountWidth = value
        '        OnPropertyChanged("CommentCountWidth")
        '    End Set
        'End Property

        'Private _VisitorCountWidth As Double
        'Public Property VisitorCountWidth() As Double
        '    Get
        '        Return _VisitorCountWidth
        '    End Get
        '    Set(ByVal value As Double)
        '        _VisitorCountWidth = value
        '        OnPropertyChanged("VisitorCountWidth")
        '    End Set
        'End Property

        'Private _ShortContentWidth As Double
        'Public Property ShortContentWidth() As Double
        '    Get
        '        Return _ShortContentWidth
        '    End Get
        '    Set(ByVal value As Double)
        '        _ShortContentWidth = value
        '        OnPropertyChanged("ShortContentWidth")
        '    End Set
        'End Property

        'Private _StationLevelWidth As Double
        'Public Property StationLevelWidth() As Double
        '    Get
        '        Return _StationLevelWidth
        '    End Get
        '    Set(ByVal value As Double)
        '        _StationLevelWidth = value
        '        OnPropertyChanged("StationLevelWidth")
        '    End Set
        'End Property

        'Private _StationMemberCountWidth As Double
        'Public Property StationMemberCountWidth() As Double
        '    Get
        '        Return _StationMemberCountWidth
        '    End Get
        '    Set(ByVal value As Double)
        '        _StationMemberCountWidth = value
        '        OnPropertyChanged("StationMemberCountWidth")
        '    End Set
        'End Property

        'Private _StationUpdateDateTimeWidth As Double
        'Public Property StationUpdateDateTimeWidth() As Double
        '    Get
        '        Return _StationUpdateDateTimeWidth
        '    End Get
        '    Set(ByVal value As Double)
        '        _StationUpdateDateTimeWidth = value
        '        OnPropertyChanged("StationUpdateDateTimeWidth")
        '    End Set
        'End Property
#End Region

#Region "Visible Properties"

        Private _IconVisible As Boolean = True
        Public Property IconVisible() As Boolean
            Get
                Return _IconVisible
            End Get
            Set(ByVal value As Boolean)
                _IconVisible = value
                OnPropertyChanged("IconVisible")
            End Set
        End Property

        Private _TitleVisible As Boolean = True
        Public Property TitleVisible() As Boolean
            Get
                Return _TitleVisible
            End Get
            Set(ByVal value As Boolean)
                _TitleVisible = value
                OnPropertyChanged("TitleVisible")
            End Set
        End Property

        Private _StationVisible As Boolean = True
        Public Property StationNameVisible() As Boolean
            Get
                Return _StationVisible
            End Get
            Set(ByVal value As Boolean)
                _StationVisible = value
                OnPropertyChanged("StationNameVisible")
            End Set
        End Property

        Private _CasterVisible As Boolean = True
        Public Property CasterVisible() As Boolean
            Get
                Return _CasterVisible
            End Get
            Set(ByVal value As Boolean)
                _CasterVisible = value
                OnPropertyChanged("CasterVisible")
            End Set
        End Property

        Private _StartDateTimeVisible As Boolean = True
        Public Property StartDateTimeVisible() As Boolean
            Get
                Return _StartDateTimeVisible
            End Get
            Set(ByVal value As Boolean)
                _StartDateTimeVisible = value
                OnPropertyChanged("StartDateTimeVisible")
            End Set
        End Property

        Private _VisitorCountVisible As Boolean = True
        Public Property VisitorCountVisible() As Boolean
            Get
                Return _VisitorCountVisible
            End Get
            Set(ByVal value As Boolean)
                _VisitorCountVisible = value
                OnPropertyChanged("VisitorCountVisible")
            End Set
        End Property

        Private _CommentCountVisible As Boolean = True
        Public Property CommentCountVisible() As Boolean
            Get
                Return _CommentCountVisible
            End Get
            Set(ByVal value As Boolean)
                _CommentCountVisible = value
                OnPropertyChanged("CommentCountVisible")
            End Set
        End Property

        Private _OfficialTagVisible As Boolean = True
        Public Property OfficialTagVisible() As Boolean
            Get
                Return _OfficialTagVisible
            End Get
            Set(ByVal value As Boolean)
                _OfficialTagVisible = value
                OnPropertyChanged("OfficialTagVisible")
            End Set
        End Property

        Private _ContentVisible As Boolean = True
        Public Property ShortContentVisible() As Boolean
            Get
                Return _ContentVisible
            End Get
            Set(ByVal value As Boolean)
                _ContentVisible = value
                OnPropertyChanged("ShortContentVisible")
            End Set
        End Property

        Private _RatingVisible As Boolean = True
        Public Property RatingVisible() As Boolean
            Get
                Return _RatingVisible
            End Get
            Set(ByVal value As Boolean)
                _RatingVisible = value
                OnPropertyChanged("RatingVisible")
            End Set
        End Property

        Private _AlertMannersVisible As Boolean = True
        Public Property AlertMannersVisible() As Boolean
            Get
                Return _AlertMannersVisible
            End Get
            Set(ByVal value As Boolean)
                _AlertMannersVisible = value
                OnPropertyChanged("AlertMannersVisible")
            End Set
        End Property

        Private _StationLevelVisible As Boolean = True
        Public Property StationLevelVisible() As Boolean
            Get
                Return _StationLevelVisible
            End Get
            Set(ByVal value As Boolean)
                _StationLevelVisible = value
                OnPropertyChanged("StationLevelVisible")
            End Set
        End Property

        Private _StationMemberCountVisible As Boolean = True
        Public Property StationMemberCountVisible() As Boolean
            Get
                Return _StationMemberCountVisible
            End Get
            Set(ByVal value As Boolean)
                _StationMemberCountVisible = value
                OnPropertyChanged("StationMemberCountVisible")
            End Set
        End Property

        Private _StationUpdateDateTimeVisible As Boolean ' = False
        Public Property StationUpdateDateTimeVisible() As Boolean
            Get
                Return _StationUpdateDateTimeVisible
            End Get
            Set(ByVal value As Boolean)
                _StationUpdateDateTimeVisible = value
                OnPropertyChanged("StationUpdateDateTimeVisible")
            End Set
        End Property
#End Region

#Region "Star"

        ' TODO FilterByStar 0～5 をひとつにまとめる
        'Private _filterByStar As ObservableCollection(Of Boolean)
        'Public ReadOnly Property FilterByStar() As ObservableCollection(Of Boolean)
        '    Get
        '        If _filterByStar Is Nothing Then
        '            _filterByStar = New ObservableCollection(Of Boolean)(New List(Of Boolean)(6))
        '        End If
        '        Return _filterByStar
        '    End Get
        'End Property

        Private _FilterByStar5 As Boolean
        Public Property FilterByStar5() As Boolean
            Get
                Return _FilterByStar5
            End Get
            Set(ByVal value As Boolean)
                _FilterByStar5 = value
                OnPropertyChanged("FilterByStar5")
            End Set
        End Property

        Private _FilterByStar4 As Boolean
        Public Property FilterByStar4() As Boolean
            Get
                Return _FilterByStar4
            End Get
            Set(ByVal value As Boolean)
                _FilterByStar4 = value
                OnPropertyChanged("FilterByStar4")
            End Set
        End Property

        Private _FilterByStar3 As Boolean
        Public Property FilterByStar3() As Boolean
            Get
                Return _FilterByStar3
            End Get
            Set(ByVal value As Boolean)
                _FilterByStar3 = value
                OnPropertyChanged("FilterByStar3")
            End Set
        End Property

        Private _FilterByStar2 As Boolean
        Public Property FilterByStar2() As Boolean
            Get
                Return _FilterByStar2
            End Get
            Set(ByVal value As Boolean)
                _FilterByStar2 = value
                OnPropertyChanged("FilterByStar2")
            End Set
        End Property

        Private _filterByStar1 As Boolean
        Public Property FilterByStar1() As Boolean
            Get
                Return _filterByStar1
            End Get
            Set(ByVal value As Boolean)
                _filterByStar1 = value
                OnPropertyChanged("FilterByStar1")
            End Set
        End Property

        Private _FilterByStar0 As Boolean
        Public Property FilterByStar0() As Boolean
            Get
                Return _FilterByStar0
            End Get
            Set(ByVal value As Boolean)
                _FilterByStar0 = value
                OnPropertyChanged("FilterByStar0")
            End Set
        End Property

        Private _ResetFilterByStarCommand As ICommand
        Public ReadOnly Property ResetFilterByStarCommand() As ICommand
            Get
                If _ResetFilterByStarCommand Is Nothing Then
                    _ResetFilterByStarCommand = New RelayCommand(New Action(Of Object)(AddressOf Me.ResetFilterByStar))
                End If
                Return _ResetFilterByStarCommand
            End Get
        End Property

        Private Sub ResetFilterByStar(ByVal obj As Object)
            FilterByStar5 = False
            FilterByStar4 = False
            FilterByStar3 = False
            FilterByStar2 = False
            FilterByStar1 = False
            FilterByStar0 = False
        End Sub

#End Region

#Region "Filter"
        Private _FilterByChannel As Boolean
        Public Property FilterByChannel() As Boolean
            Get
                Return _FilterByChannel
            End Get
            Set(ByVal value As Boolean)
                _FilterByChannel = value
                OnPropertyChanged("FilterByChannel")
            End Set
        End Property

        Private _FilterByCommunity As Boolean
        Public Property FilterByCommunity() As Boolean
            Get
                Return _FilterByCommunity
            End Get
            Set(ByVal value As Boolean)
                _FilterByCommunity = value
                OnPropertyChanged("FilterByCommunity")
            End Set
        End Property

        Private _FilterByMemberOnly As Boolean
        Public Property FilterByMemberOnly() As Boolean
            Get
                Return _FilterByMemberOnly
            End Get
            Set(ByVal value As Boolean)
                _FilterByMemberOnly = value
                OnPropertyChanged("FilterByMemberOnly")
            End Set
        End Property

        Private _FilterByFace As Boolean
        Public Property FilterByFace() As Boolean
            Get
                Return _FilterByFace
            End Get
            Set(ByVal value As Boolean)
                _FilterByFace = value
                OnPropertyChanged("FilterByFace")
            End Set
        End Property

        Private _FilterByReserved As Boolean
        Public Property FilterByReserved() As Boolean
            Get
                Return _FilterByReserved
            End Get
            Set(ByVal value As Boolean)
                _FilterByReserved = value
                OnPropertyChanged("FilterByReserved")
            End Set
        End Property

        Private _FilterByAlertTarget As Boolean
        Public Property FilterByAlertTarget() As Boolean
            Get
                Return _FilterByAlertTarget
            End Get
            Set(ByVal value As Boolean)
                _FilterByAlertTarget = value
                OnPropertyChanged("FilterByAlertTarget")
            End Set
        End Property

        Private _FilterByOnAir As Boolean
        Public Property FilterByOnAir() As Boolean
            Get
                Return _FilterByOnAir
            End Get
            Set(ByVal value As Boolean)
                _FilterByOnAir = value
                OnPropertyChanged("FilterByOnAir")
            End Set
        End Property

        Private _FilterByOffAir As Boolean
        Public Property FilterByOffAir() As Boolean
            Get
                Return _FilterByOffAir
            End Get
            Set(ByVal value As Boolean)
                _FilterByOffAir = value
                OnPropertyChanged("FilterByOffAir")
            End Set
        End Property
#End Region

#Region "Commands"
        Private _ShowAllColumnsCommand As ICommand
        Public ReadOnly Property ShowAllColumnsCommand() As ICommand
            Get
                If _ShowAllColumnsCommand Is Nothing Then
                    _ShowAllColumnsCommand = New RelayCommand(New Action(Of Object)(AddressOf Me.ShowAllColumns))
                End If
                Return _ShowAllColumnsCommand
            End Get
        End Property

        Private Sub ShowAllColumns(ByVal obj As Object)
            IconVisible = True
            TitleVisible = True
            CasterVisible = True
        End Sub


        Public Event RequestSetGroup As EventHandler(Of GroupEventArgs)
        Protected Overridable Sub OnSetGroup(ByVal e As GroupEventArgs)
            RaiseEvent RequestSetGroup(Me, e)
        End Sub

        Private _SetGroupCommand As ICommand
        Public ReadOnly Property SetGroupCommand() As ICommand
            Get
                If _SetGroupCommand Is Nothing Then
                    _SetGroupCommand = New RelayCommand(New Action(Of Object)(AddressOf Me.SetGroup))
                End If
                Return _SetGroupCommand
            End Get
        End Property

        Private Sub SetGroup(ByVal obj As Object)
            Dim value = [Enum].Parse(GetType(Grouping.ProgramGroup), CStr(obj))
            Group = DirectCast(value, Grouping.ProgramGroup)
            OnSetGroup(New GroupEventArgs(Group))
        End Sub

        Public Sub RefreshGroup()
            SetGroup(Me.Group)
        End Sub

#End Region

    End Class

End Namespace
